constraint layout: Add debug output for guides
authorMatthias Clasen <mclasen@redhat.com>
Fri, 28 Jun 2019 22:55:39 +0000 (22:55 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Sun, 30 Jun 2019 23:10:11 +0000 (00:10 +0100)
Print out the allocation we end up giving to
guides. This helps in making sense of the
allocations of the child widgets that these
guides relate to.

gtk/gtkconstraintlayout.c

index 378e7840af8f44ebd751957f61639ad494ca98b6..23bf8631c61883cfcb73e17671703858e9c63471 100644 (file)
@@ -974,6 +974,30 @@ gtk_constraint_solver_add_constraint (solver,
                                 child_baseline);
     }
 
+#ifdef G_ENABLE_DEBUG
+  if (GTK_DEBUG_CHECK (LAYOUT))
+    {
+      GHashTableIter iter;
+      gpointer key;
+      g_hash_table_iter_init (&iter, self->guides);
+      while (g_hash_table_iter_next (&iter, &key, NULL))
+        {
+          GtkConstraintGuide *guide = key;
+          GtkConstraintVariable *var_top, *var_left, *var_width, *var_height;
+          var_top = gtk_constraint_guide_get_attribute (guide, GTK_CONSTRAINT_ATTRIBUTE_TOP);
+          var_left = gtk_constraint_guide_get_attribute (guide, GTK_CONSTRAINT_ATTRIBUTE_LEFT);
+          var_width = gtk_constraint_guide_get_attribute (guide, GTK_CONSTRAINT_ATTRIBUTE_WIDTH);
+          var_height = gtk_constraint_guide_get_attribute (guide, GTK_CONSTRAINT_ATTRIBUTE_HEIGHT);
+          g_print ("Allocating guide '%s'[%p] with { .x: %g .y: %g .w: %g .h: %g }\n",
+                   gtk_constraint_guide_get_name (guide), guide,
+                   gtk_constraint_variable_get_value (var_left),
+                   gtk_constraint_variable_get_value (var_top),
+                   gtk_constraint_variable_get_value (var_width),
+                   gtk_constraint_variable_get_value (var_height));
+        }
+    }
+#endif
+
   /* The constraints on the children sizes can be removed now */
   for (guint i = 0; i < size_constraints->len; i++)
     {